package com.miyake.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.miyake.client.datamanage.Alias;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class DsAlias {
	@PrimaryKey 
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)  
	private Key key;
	
	@Persistent
	private String nodeKey;
	
	@Persistent
	private String aliasKey;
	
	@Persistent
	private Integer type;

	public String getEncodedKey() {
		return KeyFactory.keyToString(key);
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public String getAliasKey() {
		return aliasKey;
	}

	public void setAliasKey(String aliasKey) {
		this.aliasKey = aliasKey;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getNodeKey() {
		return nodeKey;
	}

	public void setNodeKey(String nodeKey) {
		this.nodeKey = nodeKey;
	}

	public Alias toRemoteObject() {
		Alias ret = new Alias();
		ret.setKey(getEncodedKey());
		ret.setAliasKey(aliasKey);
		ret.setType(type);
		return ret;
	}
	
}
